package com.reagent.system.controller;


import com.reagent.system.entity.User;
import com.reagent.system.service.UserService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "用户接口")
@ApiResponses({
        @ApiResponse(code = 200, message = "成功"),
        @ApiResponse(code = 201, message = "成功创建资源"),
        @ApiResponse(code = 400, message = "失败"),
        @ApiResponse(code = 401, message = "服务器认证失败"),
        @ApiResponse(code = 403, message = "资源不存在"),
        @ApiResponse(code = 404, message = "页面不存在"),
        @ApiResponse(code = 500, message = "服务器异常")
})
@RestController
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;


    @ApiOperation(value = "用户登录", notes = "通过用户名和密码查询用户信息并登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "password", value = "用户密码", paramType = "query", dataType = "String")
    })
    @PostMapping("/logincheck")
    public Object logincheck(@RequestBody User user) {
        return userService.logincheck(user);
    }


    @ApiOperation(value = "用户注册", notes = "通过用户名和密码注册用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "password", value = "用户密码", paramType = "query", dataType = "String")
    })
    @PostMapping("/signInfo")
    public Object signInfo(@RequestBody User user) {
        return userService.signInfo(user);

    }

}

